package com.ojoin.trade.common_core.web.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ojoin.trade.common.constdef.IConstDef;
import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.web.dao.BaseDao;
import com.ojoin.trade.common.web.service.impl.BaseServiceImpl;
import com.ojoin.trade.common_core.web.dao.TbMerchantuserExceptionorderDao;
import com.ojoin.trade.common_core.web.domain.TbMerchantuserExceptionorder;
import com.ojoin.trade.common_core.web.service.TbMerchantuserExceptionorderBaseService;

/**
 * Created with IntelliJ IDEA. User: Administrator Date: 15-11-17 Time: 上午10:29
 * To change this template use File | Settings | File Templates.
 */
@Service
public class TbMerchantuserExceptionorderBaseServiceImpl extends
		BaseServiceImpl<TbMerchantuserExceptionorder> implements TbMerchantuserExceptionorderBaseService {
	@Autowired
	private TbMerchantuserExceptionorderDao tbMerchantInfoDao;
	
	@Autowired
	private DataVersionValidationService validationService;

	@Override
	protected BaseDao<TbMerchantuserExceptionorder> getBaseDao() {
		return tbMerchantInfoDao;
	}

	@Override
	public List<TbMerchantuserExceptionorder> queryExceOrderByJoinuserID(
			int joinuserid) throws BusinessException {
		return ((TbMerchantuserExceptionorderDao)getBaseDao()).queryExceOrderByJoinuserID(joinuserid);
	}

	@Override
	public int updateVOById(TbMerchantuserExceptionorder order)
			throws BusinessException {
		return ((TbMerchantuserExceptionorderDao)getBaseDao()).updateVOById(order);
	}

	@Override
	public int updateVOByOrderId(TbMerchantuserExceptionorder order)
			throws BusinessException {
		return ((TbMerchantuserExceptionorderDao)getBaseDao()).updateVOByOrderId(order);
	}
	
	@Override
	public boolean isFreezeByJoinuserID(int joinuserid)
			throws BusinessException {
		List<TbMerchantuserExceptionorder> list = queryExceOrderByJoinuserID(joinuserid);
		if (list == null || list.size() == 0)
			return false;
		
		for(TbMerchantuserExceptionorder order : list) {
			if (order.getAccountStatus() == IConstDef.ACCOUNT_STATUS_FREEZE)
				return true;
		}
		return false;
	}

	@Override
	public TbMerchantuserExceptionorder queryExceOrderByOrderID(String orderid)
			throws BusinessException {
		return ((TbMerchantuserExceptionorderDao)getBaseDao()).queryExceOrderByOrderID(orderid);
	}

	@Override
	public Integer insertMerchantuserExceptionorder(TbMerchantuserExceptionorder vo)
			throws BusinessException {
		this.getBaseDao().insert(vo);
		return vo.getId();
	}

}
